<template>
  <div class="updateBalance">
    <div style="padding-left: 50px; padding-top: 50px">
      <!-- 图片 -->
      <div class="tupian">
        <el-avatar
          :size="110"
          src="https://cdn7.axureshop.com/demo2023/2236859/images/%E5%AE%A1%E6%89%B9%E8%AF%A6%E6%83%85_%E5%8F%AF%E4%BB%A5%E6%93%8D%E4%BD%9C/u6203.png"
        ></el-avatar>
      </div>
      <div class="hh">
        <span style="font-size: 25px">{{ form.username }}的假期使用详情</span>
        <div style="margin-top: 20px; font-size: 14px; color: #a9a9a9">
          <span>工号：{{ form.id }}</span
          >&nbsp;&nbsp;&nbsp;
          <span>部门：{{ form.deptName }}</span>
        </div>
      </div>
    </div>
    <div style="margin-top: 150px; padding-left: 50px">
      当前<span>{{ form.holidayType }}余额：{{ form.duration }}天</span
      >&nbsp;&nbsp;&nbsp;
      <el-button type="primary" plain @click="hhh()" size="mini"
        >修改余额</el-button
      >
    </div>
<div class="cc">
<el-descriptions  direction="vertical" :column="4" border>
  <el-descriptions-item label="操作时间"> {{form.entryTime}}</el-descriptions-item>
  <el-descriptions-item label="操作人">{{form.nickName}}</el-descriptions-item>
  <el-descriptions-item label="操作内容">
   使用{{form.holidayType}}{{form.duration}}天
  </el-descriptions-item>
   <el-descriptions-item label="操作时长">
   -{{form.duration}}
  </el-descriptions-item>
</el-descriptions>
</div>
    <el-dialog title="修改" :visible.sync="dialogVisible" width="40%">
      <el-form :inline="true" :model="form" class="demo-form-inline">
        <el-form-item label="修改天数">
          <el-input-number v-model="form.duration" ></el-input-number>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="update()">修改</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "updateBalance",
  data() {
    return {
      title:"",
      //弹框
      dialogVisible: false,
      tableData: [],
      form: {
        username:"",
        id: "",
        nickName: "",
        deptName: "",
        positionName: "",
        holidayType: "",
        duration: "",
      },
    };
  },
  created() {
    this.searchList();
  },
  methods: {
    //修改弹框
    hhh() {
      this.dialogVisible = true;
    },
    //修改
    update() {
      this.$http.post("auditCenter/updateBalance", this.form).then((res) => {
        if (res.data.code == 200) {
          this.$message({
            message: "恭喜你，修改成功",
            type: "success",
          });
          this.$router.push({ path: "/balance" });
        } else {
          this.$message.error("错了哦，修改失败");
        }
      });
    },
    //回显
    searchList() {
      this.$http
        .get("auditCenter/findBalanceById?id=" + this.$route.query.id)
        .then((res) => {
          this.form = res.data;
          this.form.id = this.$route.query.id;
        });
    },
  },
};
</script>

<style scoped>
.cc {
  margin-top: 30px;
}
.tupian {
  display: block;
  float: left;
}
.hh {
  display: block;
  float: left;
  padding-left: 50px;
  padding-top: 15px;
}
</style>